﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AccManagerKw.Startup;
using Utilities;

namespace AccManagerKw
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException +=
            new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                CultureInfo en = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = en;
                DevExpress.UserSkins.BonusSkins.Register();
                DevExpress.UserSkins.OfficeSkins.Register();
                DevExpress.Skins.SkinManager.EnableMdiFormSkins();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                //var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                //var connectionStrings = config.ConnectionStrings.ConnectionStrings["AccManagerEntities"];
                //ClsCommonFn oClsCommFn = new ClsCommonFn();
                //oClsCommFn.SetConnString(connectionStrings);

                Application.Run(new FrmSplash());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = (Exception)e.ExceptionObject;

                MessageBox.Show(string.Format("Whoops! Please contact the developers with the following information:\n\n{0}{1}", ex.Message, ex.StackTrace), "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //var objUser = new UserMasterBo();
                //objUser.SaveLogOut_Detail(Global_Info.Get_ConnetString);
            }
            finally
            {
                Application.Exit();
                Application.ExitThread();
            }
        }
    }
}
